BEGIN;
	CREATE TABLE offers(
		id BIGSERIAL PRIMARY KEY,
		request_id BIGINT NOT NULL,
		item_id BIGINT NOT NULL,
		offered_at TIMESTAMPTZ DEFAULT now(),
		offered_by_id BIGINT NOT NULL, -- This is the id of the facebook user who created the offer
		item_owner_agreed BOOLEAN DEFAULT false,
		requester_agreed BOOLEAN DEFAULT false,
		canceled BOOLEAN DEFAULT false,
		return_due_date DATE,
		return_actual_time TIMESTAMPTZ,
		UNIQUE(request_id,item_id)
	);
	CREATE INDEX offers_request_id_index ON offers (request_id);
	CREATE INDEX offers_item_id_index ON offers (item_id);
	CREATE INDEX offers_offered_by_id_index ON offers (offered_by_id);
	CREATE INDEX offers_return_due_date_index ON offers (return_due_date);
END;
